<template>
  <div class="mine">
    <div class="headpic">
      <img class="pic" src="../images/58.png" alt />
      <!-- <p class="username" v-if="change"></p> -->
      <p class="username">{{ username }}</p>
    </div>
    <div class="order">
      <div class="box1">
        <span class="sp1">全部订单</span>
        <span class="sp2">
          查看全部订单
          <span class="arrow-right"></span>
        </span>
      </div>
      <ul class="box2">
        <li>
          <a href="###">
            <span class="icon_k"></span>
            <strong>代付款</strong>
          </a>
        </li>
        <li>
          <a href="###">
            <span class="icon_f"></span>
            <strong>代发货</strong>
          </a>
        </li>
        <li>
          <a href="###">
            <span class="icon_s"></span>
            <strong>代收货</strong>
          </a>
        </li>
      </ul>
    </div>
    <div class="duobao">
      <div class="duobaobox">
        <div class="sp1">夺宝记录</div>
        <span class="arrow-right"></span>
      </div>
    </div>
    <div class="bananabi">
      <div class="duobaobox">
        <div class="sp1">Banana币</div>
        <span class="sp2">
          您有0.00个Banana币可用
          <span class="arrow-right"></span>
        </span>
      </div>
    </div>
    <div class="shoucang">
      <div class="duobaobox">
        <div class="sp1">我的收藏</div>
        <span class="arrow-right"></span>
      </div>
    </div>
    <div class="adr">
      <div class="duobaobox">
        <div class="sp1">我的地址</div>
        <span class="arrow-right"></span>
      </div>
    </div>
    <div class="login" @click="goto('/login')" v-if="change">登录</div>
    <div class="login" @click="leave()" v-else>退出登录</div>
  </div>
</template>

<script>
// import "../js/rem";
export default {
  inject: ["reload"],
  data: function() {
    return {
      username: ""
    };
  },
  created() {
    let str = localStorage.getItem("authorization");
    if (str) {
      let token = JSON.parse(str);
      let name = token.username;
      this.username = name;
    } else {
      this.username = "";
    }

    // if (name) {

    // } else {
    //   this.username = '1'
    // }
  },

  methods: {
    goto(path) {
      this.$router.push(path);
    },
    leave() {
      this.$store.commit("logout");
      this.reload();
      // window.console.log(this);
      this.$store.state.cart.cartlist = [];
    }
  },
  computed: {
    change() {
      let token = localStorage.getItem("authorization");
      if (token) {
        return false;
      } else {
        return true;
      }
    }
  }
};
</script>

<style scoped lang="scss">
.mine {
  height: 100%;
  width: 100%;
  background: #f6f6f6;
  .headpic {
    width: 100%;
    background: #fff;
    margin-bottom: 0.266667rem;
    text-align: center;
    padding: 0.8rem 0;
    .pic {
      height: 1.6rem;
      width: 1.6rem;
      margin: auto;
      border: 1px solid #fff;
      border-radius: 50%;
      //   background: url(../images/58.png) no-repeat;
    }
    .username {
      font-size: 0.426667rem;
      line-height: 0.426667rem;
      margin-top: 0.133333rem;
    }
  }
  .order {
    background: #fff;
    .box1 {
      margin: 0 0.266667rem;
      border-bottom: 0.026667rem solid #ededed;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .sp1 {
        color: #000;
        font-size: 0.373333rem;
        line-height: 1.093333rem;
        cursor: pointer;
      }
      .sp2 {
        font-size: 0.32rem;
        line-height: 1.093333rem;
        color: #999;
        position: relative;
        padding-right: 0.466667rem;
        cursor: pointer;
      }
    }
    .box2 {
      margin: 0 0.266667rem;
      display: flex;
      justify-content: space-around;
      align-items: center;
      padding-top: 0.266667rem;
      li {
        a {
          display: inline-block;
          display: flex;
          flex-direction: column;
          justify-content: center;
          span {
            display: inline-block;
            width: 0.666667rem;
            height: 0.666667rem;
            background: url(../images/i2.png) no-repeat;
            background-size: 300%;
            margin: auto;
          }
          strong {
            font-size: 0.32rem;
            color: #666;
            font-weight: 400;
            padding: 0.186667rem 0;
            cursor: pointer;
          }
        }
        .icon_k {
          background-position: 0 0;
        }
        .icon_f {
          background-position: -0.666667rem 0;
        }
        .icon_s {
          background-position: -1.333333rem 0;
        }
      }
    }
  }
  .duobao {
    margin: 0.266667rem 0;
    background: #fff;

    border-bottom: 0.013333rem solid #ededed;
    .duobaobox {
      margin: 0 0.266667rem;
      display: flex;
      justify-content: space-between;
      position: relative;
      .sp1 {
        display: inline-block;
        font-size: 0.373333rem;
        line-height: 1.093333rem;
        color: #000;
      }
    }
  }
  .bananabi {
    margin-bottom: 0.266667rem;
    background: #fff;

    border-bottom: 0.013333rem solid #ededed;
    .duobaobox {
      margin: 0 0.266667rem;
      display: flex;
      justify-content: space-between;
      position: relative;
      .sp1 {
        display: inline-block;
        font-size: 0.373333rem;
        line-height: 1.093333rem;
        color: #000;
      }
      .sp2 {
        font-size: 0.32rem;
        line-height: 1.093333rem;
        color: #000;
        position: relative;
        padding-right: 0.466667rem;
        cursor: pointer;
      }
    }
  }
  .shoucang {
    background: #fff;
    border-bottom: 0.013333rem solid #ededed;
    .duobaobox {
      margin: 0 0.266667rem;
      display: flex;
      justify-content: space-between;
      position: relative;
      .sp1 {
        display: inline-block;
        font-size: 0.373333rem;
        line-height: 1.093333rem;
        color: #000;
      }
    }
  }
  .adr {
    background: #fff;
    border-bottom: 0.013333rem solid #ededed;
    .duobaobox {
      margin: 0 0.266667rem;
      display: flex;
      justify-content: space-between;
      position: relative;
      .sp1 {
        display: inline-block;
        font-size: 0.373333rem;
        line-height: 1.093333rem;
        color: #000;
      }
    }
  }
  .login {
    margin: auto;
    margin-top: 0.8rem;
    width: 8rem;
    height: 1.333333rem;
    background: #000;
    color: #fff;
    font-size: 0.4rem;
    line-height: 1.333333rem;
  }
  .arrow-right {
    border-right: 2px solid #999;
    border-top: 2px solid #999;
    height: 10px;
    margin-top: -5px;
    position: absolute;
    right: 0.16rem;
    top: 50%;
    transform: rotate(45deg);
    width: 10px;
  }
}
</style>